The optimal control of the attitude motion of 3D rigid pendulum with initial disturbance is investigated. Combined with the characteristics of the attitude and angular velocity of the 3D rigid pendulum, the closed-loop feedback attitude tracking controller is designed for the external disturbance. Firstly, 3D rigid pendulum attitude trajectory is designed for open loop by use of Legendre pseudospectra method. Then the system’s motion equation is linearized, and the difference between the attitude reference trajectory and actual trajectory motion in 3D rigid pendulum is considered as control variable. Attitude tracking problem is converted to linear time-varying systems attitude regulation problem. Finally, the closed-loop control based on the Legendre pseudospectral method is simulated and analyzed for the optimal control of 3D rigid pendulum, and simulations show that the effectiveness in the case of initial disturbance.